import operate from '@dfeidao/atom-nodejs/db/operate';
import log from '@dfeidao/atom-nodejs/logger/log';
import { systemid } from '../../atom/config';
interface Message {
	train_number: string;
	name_training_material: string;
	address_training_material: string;
}


// 表名	train_material
// 标题	培训资料
// 字段名称	字段标题	字段类型	字段长度	是否为空	是否主键
// _id	id	string	50	ⅹ	√
// productid	产品ID	string	50	√	ⅹ
// train_number	培训编号	string	64	√	ⅹ
// name_training_material	培训资料名称	string	64	√	ⅹ
// address_training_material	培训资料地址	document	64	√	ⅹ

export default async function atom(msg: Message, action_id: string, session_id: string) {
	log(`Service begin`);
	const { exec, insert } = await operate(action_id, session_id, systemid);
	insert('train_material', { 'train_number': msg.train_number, 'name_training_material': msg.name_training_material, 'address_training_material': msg.address_training_material });
	const res = await exec();
	return res;
}
